import { defHttp } from '/@/utils/http/axios';
import { Modal } from 'ant-design-vue';

enum Api {
  operationAccessTopic = '/operation/operationAccessTopic/list',
  operationAccessTopicAdd = '/operation/operationAccessTopic/add',
  operationAccessTopicDelete = '/operation/operationAccessTopic/delete',
  operationAccessTopicEdit = '/operation/operationAccessTopic/edit',
  operationAccessTopicDeleteBatch = '/operation/operationAccessTopic/deleteBatch'
}
/**
 * 列表接口-主题
 * @param params
 */
export const getOperationAccessTopic = (params) =>
  defHttp.get({ url: Api.operationAccessTopic, params });
  
  /**
   * 删除单个-主题
   * @param params
   * @param handleSuccess
   */
  export const getOperationAccessTopicDeleteOne = (params, handleSuccess) => {
    return defHttp.delete({ url: Api.operationAccessTopicDelete, params }, { joinParamsToUrl: true }).then(() => {
      handleSuccess();
    });
  }
  /**
   * 批量删除-主题
   * @param params
   * @param handleSuccess
   */
  export const getOperationAccessTopicDeleteBatchDelete = (params, handleSuccess) => {
    Modal.confirm({
      title: '确认删除',
      content: '是否删除选中数据',
      okText: '确认',
      cancelText: '取消',
      onOk: () => {
        return defHttp.delete({ url: Api.operationAccessTopicDeleteBatch, data: params }, { joinParamsToUrl: true }).then(() => {
          handleSuccess();
        });
      }
    });
  }
  /**
   * 保存或者更新-主题
   * @param params
   * @param isUpdate 是否是更新数据
   */
  export const getOperationAccessTopicSaveOrUpdate = (params, isUpdate) => {
    let url = isUpdate ? Api.operationAccessTopicEdit : Api.operationAccessTopicAdd;
    return defHttp.post({ url: url, params });
  }
  